package com.mandao.concurrency.example.singleton;

import com.mandao.concurrency.annotations.NotThreadSafe;

/**
 *  懒汉式
 *      单例实例在第一次使用时创建
 *  单线程没问题 多线程时有问题
 */
@NotThreadSafe
public class SingletonExample1 {
    private SingletonExample1(){}

    private static SingletonExample1 instance = null;

    public static SingletonExample1 getInstance(){
        if (null == instance){
            instance = new SingletonExample1();
        }
        return instance;
    }
}
